<template>
    <component
        :is="metadata.control.type=='window'?'M-'+metadata.type+'-lattice':'M-'+metadata.type"
        ref="current"
        v-model="value"
        :data="data"
        :metadata="metadata"
        :readOnly="readOnly"
    ></component>
</template>

<script>
import components from "./index"
export default {
    name: "MComponent",
    emits: ['update:modelValue'],
    components:components,
    props: {
        /**
         *当前控件值
         */
        modelValue: {
        },
        /**
         *上下文全部数据
         */
        data: {
            type: Object,
        },
        /**
         * 控件属性
         */
        metadata: {
            type: Object
        },
        /**
         *表单只读
         */
        readOnly: {
            default: () => {
                return false
            }
        },
    },
    data(){
        return{
            value:''
        }
    },
    watch:{
        modelValue:{
            handler(){
                this.value = this.modelValue;
            },
            deep:true,
            immediate:true
        },
        value:{
            handler(val){
                this.$emit('update:modelValue', val);
            },
            deep:true
        }
    }
}
</script>

<style scoped>

</style>
